
const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    @property(cc.Label)
    numLabel:cc.Label=null;
    // LIFE-CYCLE CALLBACKS:

    timeNum=5;

    str:string="5"

    count=5;

     onLoad () {

     }

    start () {
        this.numLabel.string=this.timeNum+"";
        this.schedule(()=>{
            this.timeNum--;
            this.numLabel.string=this.timeNum+"";
            if(this.timeNum==-1){
                this.timeNum=0;
                this.numLabel.string="0";
                this.goToGame();   
            }
        },1);

        



    }

    callback(){
        if (this.count === 0) {
            this.timeNum=0;
            // 在第3次执行回调时取消这个计时器
            this.unschedule(this.callback);
        }
        
            this.count--;
    }
    //使用中
    rCk(){
        this.count = 5;
        this.numLabel.string=this.count+"";
        this.callback();
        this.schedule(this.callback, 1);
    }

    goToGame(){
       cc.director.loadScene("game");
    }
    // update (dt) {}
}
